﻿/*  
 *  IIS LogFile Analyser, Copyright (C) 2013. http://www.iis-analyser.com
 *  --
 *  This program is free software, provided "AS IS" WITHOUT ANY WARRANTY; without even the implied warranty of 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
 * 
 *  File Author: Ian Quigley,    2013-02-23
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataStore;
using AppLogic;

namespace LogProcess
{
    public class AddSiteCommand : ICommandAction
    {
        public string Process( CommandParameters parameters )
        {
            var store = new Store( (string)parameters["DatabaseFile"] );
            var site = store.FindOrCreateSite( (string)parameters["Name"], (string)parameters["Folder"] );
            if (site == null)
                return "Failed to create site";
            
            return null;
        }

        public string Description()
        {
            return "Add a site to the database.";
        }

        public List<CommandParameter> Parameters
        {
            get 
            {
                return new List<CommandParameter>() 
                    {
                        new CommandParameter() { Name = "DatabaseFile", Type= CommandParameterType.String},
                        new CommandParameter() { Name = "Name", Type= CommandParameterType.String},
                        new CommandParameter() { Name = "Folder", Type=CommandParameterType.Folder}
                    };
            }
        }
    }
}
